package main

import "fmt"

//匿名闭包
func addUpper() func(int) int {
	//值初始化一次，然后不断被赋予新的值
	var n int = 10
	return func(x int) int {
		n += x
		return n
	}
}

func main() {
	f := addUpper()

	res1 := f(1)
	fmt.Println("res1的值", res1)

	res2 := f(2)
	fmt.Println("res2的值", res2)

	res3 := f(3)
	fmt.Println("res3的值", res3)

	res4 := f(4)
	fmt.Println("res4的值", res4)

}
